#!/usr/bin/python
import sys
import os
import gzip
import time
_PATH = os.path.dirname(os.path.abspath(__file__))
_LIB = os.path.join(_PATH, "../src")
sys.path.append(_LIB)
import fpgrowth
from fpgrowth import fim

fpgrowth.VERB = True

def load_tdb():
    f = gzip.open(os.path.join(_PATH, "../data/flickr_tags_usa.txt.gz"))
    tdb = []
    for l in f:
        tags = l.strip().split(" ")
        tdb.append(tuple(tags))
    return tdb

if __name__ == "__main__":
    tdb = load_tdb()
    mc = 15000

    t = time.time()
    res = fim(tdb, mc)
    print time.time()-t
    print len(res)

    #from profile import run
    #run("fim(tdb, mc, False)")


